package cn.o.exceptions;

import java.io.Serializable;

import static cn.o.exceptions.ExpCodePrefix.*;


/**
 * @Description:
 * @Author: Zhou Chenyu
 * @Date: 2018/6/15
 * @Version: V1.0
 * @Modified By:
 * @Modified Date:
 * @Why:
 */
public enum ExceptionEnum implements Serializable {

    /** 通用异常 */
    UNKNOW_ERROR(COMMON_EXP_PREFIX + "000", "未知异常"),
    ERROR_404(COMMON_EXP_PREFIX + "001", "服务404"),
    PARAM_NULL(COMMON_EXP_PREFIX + "002", "参数为空"),
    NO_REPEAT(COMMON_EXP_PREFIX + "003", "请勿重复提交"),
    TOKEN_NULL(COMMON_EXP_PREFIX + "004", "TOKEN不存在"),
    TOKEN_EXPIRED(COMMON_EXP_PREFIX + "005", "TOKEN超时"),
    TOKEN_ERROR(COMMON_EXP_PREFIX + "006", "TOKEN错误"),
    HTTP_REQ_METHOD_ERROR(COMMON_EXP_PREFIX + "007", "HTTP请求方法不正确"),
    JSON_ERROR(COMMON_EXP_PREFIX + "008", "JSON解析异常"),
    NO_PERMISSION(COMMON_EXP_PREFIX + "009", "当前用户无此操作权限"),
    CREATE_FAIL(COMMON_EXP_PREFIX + "010", "新增失败"),
    UPDATE_FAIL(COMMON_EXP_PREFIX + "011", "更新失败"),
    DELETE_FAIL(COMMON_EXP_PREFIX + "012", "删除失败"),
    QUERY_FAIL(COMMON_EXP_PREFIX + "013", "查询失败"),

    /** Feign模块异常 */
    HYSTRIX(FEIGN_EXP_PREFIX + "000", "服务暂时失效，请重试"),

    /** User模块异常 */
    ACCOUNT_NULL(USER_EXP_PREFIX + "000", "用户名为空"),
    USER_NULL(USER_EXP_PREFIX + "001", "用户不存在"),
    USER_INVALID(USER_EXP_PREFIX + "002", "用户失效"),
    PASSWORD_NULL(USER_EXP_PREFIX + "011", "密码为空"),
    PASSWORD_ERROR(USER_EXP_PREFIX + "012", "密码错误"),
    PASSWORD_CHANGE_FAIL(USER_EXP_PREFIX + "013", "密码修改失败"),
    PASSWORD_DIFFERENT(USER_EXP_PREFIX + "014", "两次输入的密码不一致"),

    /** Attachment模块异常 */
    UPLOAD_FAIL(ATTACHMENT_EXP_PREFIX + "000", "文件上传失败");


    private String code;
    private String message;

    ExceptionEnum(){}

    ExceptionEnum(String code, String message){
        this.code = code;
        this.message = message;
    }


    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
